<span style="font-size:14px;"><!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>用js实现每隔一秒刷新时间(含年月日时分秒)</title>
<style>
#time {
    background: #33F;
    color: white;
    text-align: center;
    margin: 0 auto;
    margin-top: 200px;
}
</style>
</head>
<body>
	<div id="time"></div>
	<script type="text/javascript"> 
	 setInterval(function () {
         var time = new Date();
         var hour = checkTime(time.getHours());   //获取时
         var minite = checkTime(time.getMinutes());  //获取分
         var second = checkTime(time.getSeconds());  //获取秒
         /****当时、分、秒、小于10时，则添加0****/
         function checkTime(i) {
             if (i < 10) return "0" + i;
             return i;
         }

         var box = document.getElementById("time");
         box.innerHTML = hour + ":" + minite + ":" + second;
     }, 1000);     //setInterval(fn,i) 定时器，每隔i秒执行fn
</script>
</body>
</html></span><span style="font-size:32px;">
</span>
